package com.cooper.dao.seller;

import java.util.List;

import com.cooper.entity.DesignerApplyDo;
import com.cooper.pagination.PageInfo;
import com.cooper.vo.DesignerApplyVo;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.Insert;
import net.paoding.rose.jade.annotation.Paged;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.Update;

@DAO
public interface DesignerApplyDAO {

	@Insert(tableName="d_designer_apply")
	Long addDesigner(DesignerApplyDo designerApplyDo);
	
	@SQL("select * from  d_designer_apply where id=:1")
	DesignerApplyDo getDesignerApply(Long id);
	
	@SQL("select * from  d_designer_apply where deleted='n' and  user_id=:1 and status=:2")
	DesignerApplyDo getDesignerApplyByUserId(Long userId,String status);
	
	
	@Update(tableName="d_designer_apply")
	void updateDesignerApply(DesignerApplyDo designerApplyDo);
	
	
	@SQL("select count(*) from d_designer_apply a left join d_address c on (a.id=c.outer_id and c.origin='seller_address' and a.deleted='n' and c.deleted='n') where a.deleted='n'"
	+ " #if(null !=:1.sellerType && ''!=:1.sellerType){ and a.seller_type=:1.sellerType}"
	+ " #if(null !=:1.status && ''!=:1.status){ and a.status=:1.status}"
	+ " #if(null !=:1.sellerType && ''!=:1.sellerType){ and a.seller_type=:1.sellerType}"
	+ " #if(null !=:1.storeName && ''!=:1.storeName){ and a.store_name like CONCAT('%',:1.storeName,'%') } "
	)
	int queryDesignerApplyCount(DesignerApplyVo searchVo);
	
	@Paged(paramIndex=1)
	@SQL("select a.*,concat(IFNULL(c.city_name,\"\"),IFNULL(c.state_name,\"\"),IFNULL(c.country_name,\"\"),IFNULL(c.continent_name,\"\")) as str_location_names"
			+ " from d_designer_apply a left join d_address c on (a.id=c.outer_id and c.origin='seller_address' and a.deleted='n' and c.deleted='n') where 1=1"
			+ " #if(null !=:1.sellerType && ''!=:1.sellerType){ and a.seller_type=:1.sellerType}"
			+ " #if(null !=:1.status && ''!=:1.status){ and a.status=:1.status}"
			+ " #if(null !=:1.sellerType && ''!=:1.sellerType){ and a.seller_type=:1.sellerType}"
			+ " #if(null !=:1.storeName && ''!=:1.storeName){ and a.store_name like CONCAT('%',:1.storeName,'%') } "
			)
	List<DesignerApplyVo> queryForList(DesignerApplyVo searchVo, PageInfo pageInfo);
	
}
